using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Diagnostics;

using phorm.database.core;

namespace phorm.model.fields
{
    /// <summary>
    /// A variable character column.
    /// </summary>
    public class Varchar : DatabaseColumn
    {
        /// <summary>
        /// Constant default length of this column
        /// </summary>
        const int DEFAULT_LENGTH = 255;

        /// <summary>
        /// Constructor initializes and populates column into the model object with default length.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        public Varchar(DatabaseRecord obj)
        {
            this._model = obj;
            this.length = Varchar.DEFAULT_LENGTH.ToString();
            this.field_type = "varchar";

            populateColumn();
        }

        /// <summary>
        /// Constructor initializes and populates column into the model object.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        /// <param name="len">The length of this column</param>
        public Varchar(DatabaseRecord obj, int len)
        {
            this._model     = obj;
            this.length     = len.ToString();
            this.field_type = "varchar";

            populateColumn();
        }
    }
}
